/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package race.component;

import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextBox;
import race.util.Tool;

/**
 *
 * @author BBXP
 */
public class SettingForm extends Form{

    private String[] ls = {"Esay", "Normal", "Hard"};

    private ChoiceGroup cg;

    private StringItem[] levels = new StringItem[RaceCanvas.HARD];


    public SettingForm(){
        super("Option");
        
        cg = new ChoiceGroup("Diffculity", ChoiceGroup.EXCLUSIVE);
        cg.append("Easy", null);
        cg.append("Normal", null);
        cg.append("Hard", null);
        this.append(cg);
        for(int i = 0; i < RaceCanvas.HARD; i++){
            levels[i] = new StringItem(ls[i]+":", null);
            this.append(levels[i]);
        }
    }

    public int getLevel(){
        return cg.getSelectedIndex()+1;
    }

    public void refreshRecords(){
        for(int i = 0; i < ls.length; i++){
            String r = "";
            try {
                r = Tool.viewRecord(i+1)+"";
            } catch (Exception ex) {
                r = "unknown";
            }
            levels[i].setText(r);
        }
    }
    
}
